function t(t, e, a) {
    return e in t ? Object.defineProperty(t, e, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = a, t; 
}

var e, a = require("../../../utils/function.js"), n = require("../../../api.js"), o = require("../../../utils/qqmap-wx.js"), i = getApp(), s = wx.getStorageSync("MAP_KEY") || "PNIBZ-QF5R2-XSGUL-CGVXI-5J4GZ-VNFNX", r = new o({
    key: s
});

Page((e = {
    data: {
        estimated:'',
        istail:true,
        polyline: [ {
            points: [],
            color: "#0299de",
            width: 9,
            dottedLine: !1,
            arrowLine: !0
        } ],
        make: {},
        controls: [ {
            id: 1,
            // iconPath: "../../../images/user/icon-22.png",
            position: {
                right: 10,
                top: 10,
                width: 50,
                height: 50
            },
            clickable: !0
        } ],
        announcement:'',
        istail_title : '',
        address: {},
        startAddress: {},
        order_going_m: 0,
        order_going_s: 0,
        myShow: !0,
        zuoyou: "icon-zuoyou",
        avatar: "../../../images/user/icon-07.png",
        buttonText: "登录",
        username: "未登录",
        orderGoing: !1,
        homeHandlerShow: !0,
        phone: "",
        order_no: "",
        is_send: 0,
        left_width: 700,
        timeTaskHandler: "",
        time: "",
        t: "00:01",
        get_order: wx.getStorageSync("get_order")
    },
//   aaaaaaaaaaaaaaaaa
    resetCenter: function() {
        var t = this;
        a.getLatLntHandler(function(l) {
            t.setData({
                userAddress: l,
                startAddress: l
            });
        });
    },
    relstiveServerHandler: function() {
        a.callPhoneHandler(wx.getStorageSync("serverphone"));
    },
    // musicPlay: function (e) {
    //     var t = wx.getBackgroundAudioManager();
    //     t.title = "订单提醒", t.src = e;
    // },
    onLoad: function(t) {
        // musicPlay(wx.getStorage({
        //   key: 'newmp',
        // }))
        console.log(t);
        wx.setStorageSync('order_no', t.order_no)
        if(i.travel_type == 1){
            
            this.setData({
                istail:false
            })
        }
        this.setData({
            order_no: t.order_no,
        }),
         t.uid && i.shareCouponsMessage(t.uid);
    },
    regionchange: function(t) {},
    markertap: function(t) {},
    controltap: function(t) {
        var e = this;
        if (1 === t.controlId) wx.navigateTo({
            url: "/pages/map/my/my"
        }); else a.getLatLntHandler(function(t) {
            e.setData({
                address: t
            });
        });
    },
    timeTask: function() {
        var t = this.data.order_going_s, e = this.data.order_going_m;
        this.data.is_send;
        ++t > 59 && (t = 0, e++), this.setData({
            order_going_s: t,
            order_going_m: e
        });
    },
    deleteOrderHandler: function(t) {
        var e = this;
        wx.showModal({
            title: "提示",
            content: "确认要取消订单",
            success: function(a) {
                a.confirm && i.request({
                    url: n.order.cancel_order,
                    method: "post",
                    data: {
                        formid: t,
                        order_no: e.data.order_no
                    },
                    success: function(t) {
                        1 == t.code ? (wx.showToast({
                            title: "订单取消已成功"
                        }), clearInterval(this.timeTask), wx.reLaunch({
                            url: "../driverServer/driverServer"
                        })) : wx.showToast({
                            title: t.msg
                        });
                    }
                });
            }
        });
    },
    get_distance: function(t, e, a) {
        r.calculateDistance({
            from: {
                latitude: t.location.lat,
                longitude: t.location.lng
            },
            to: [ {
                latitude: e.location.lat,
                longitude: e.location.lng
            } ],
            success: function(t) {
                a({
                    distance: t.result
                });
            },
            fail: function(t) {
                a(t);
            },
            complete: function(t) {
                console.log(t);
            }
        });
    },
    get_line_and_count_distance: function() {
        var t = this.data.startAddress, e = this.data.endAddress;
        t && e && this.getPolyline(t, e);
    }
}, t(e, "get_distance", function(t, e, a) {
    r.calculateDistance({
        from: {
            latitude: t.location.lat,
            longitude: t.location.lng
        },
        to: [ {
            latitude: e.location.lat,
            longitude: e.location.lng
        } ],
        success: function(t) {
            a({
                distance: t.result
            });
        },
        fail: function(t) {
            a(t);
        },
        complete: function(t) {
            console.log(t);
        }
    });
}), t(e, "getPolyline", function(t, e) {
    var a = this, n = this.data.polyline, o = t.location.lat + "," + t.location.lng + "&to=" + e.location.lat + "," + e.location.lng ,p = '&policy=LEAST_DISTANCE';
    wx.request({
        url: "https://apis.map.qq.com/ws/direction/v1/driving/?from=" + o + "&key=" + s + p,
        header: {
            "content-type": "application/json"
        },
        success: function(t) {
            if (console.log(t), 384 != t.data.status) {
                for (var e = t.data.result.routes[0].polyline, o = 2; o < e.length; o++) e[o] = e[o - 2] + e[o] / 1e6;
                console.log(e);
                for (var i = [], s = 0; s < e.length; s += 2) i[i.length] = {
                    longitude: e[s + 1],
                    latitude: e[s]
                };
                n[0].points = i, console.log(n), a.setData({
                    polyline: n
                });
            }
        },
        fail: function() {}
    });
}), t(e, "mark_icon", function() {
    var t = this, e = this.data.startAddress, a = this.data.endAddress, n = [];
    e && (n[0] = {
        id: 0,
        iconPath: "/images/user/icon-44.png",
        latitude: e.location.lat,
        longitude: e.location.lng,
        width: 40,
        height: 40
    }), a && (n[1] = {
        id: 1,
        iconPath: "/images/user/icon-43.png",
        latitude: a.location.lat,
        longitude: a.location.lng,
        width: 40,
        height: 40
    }), t.setData({
        make: n
    });
}), t(e, "gotoNews", function() {
    wx.navigateTo({
        url: "/pages/user/news/news"
    });
}), t(e, "onShow", function() {
    var t = this;
    "" !== wx.getStorageSync("userMessage") && this.setData({
        avatar: wx.getStorageSync("userMessage").avatar,
        username: wx.getStorageSync("userMessage").username,
        buttonText: wx.getStorageSync("userMessage").buttonText,
        phone: wx.getStorageSync("phonep")
    });
    var e = this.data.time;
    t.postionTask(), this.setData({
        time: e
    }), a.getLatLntHandler(function(e) {
        t.setData({
            address: e,
            startAddress: e.startAddress
        });
    }), this.changeIcon(), wx.getStorageSync("get_order") && this.setData({
        get_order: wx.getStorageSync("get_order")
    });
}), t(e, "postionTask", function() {
    var t = this;
    t.data.is_send;
    i.request({
        url: n.order.waiting,
        method: "post",
        data: {
            order_no: t.data.order_no
        },
        success: function(e) {
            //语音播报
            wx.setStorageSync('newmp', "https://dishichuxing.cn" + e.data.voice_announcements )
            // i.musicPlay(wx.getStorageSync('newmp'))
            1 == e.code && (t.setData({
                is_send: e.data.is_send,
                estimated:e.data.estimated_form_time,
                startAddress: e.data.lang,
                travel_type: e.data.travel_type,
                endAddress: {
                    location: e.data.target_adds_location
                },
                waiting_time: e.data.waiting_time,
                message: e.data.message,
                distance: e.data.apart,
                price: e.data.total_price,
                is_distance: !0,
                // announcement:e.data.voice_announcements
            }), t.mark_icon(), t.get_line_and_count_distance(), t.add_time(e.data.waiting_time));
          
        },
        
    });
}), t(e, "change_time", function(t) {
    var e = t, a = Math.floor(e / 60) % 60, n = e % 60, o = "";
    a < 10 && (o += "0"), o += a + ":", n < 10 && (o += "0"), o += n, console.log(o, "132456789123456789");
    var i = this.data.waiting_time;
    this.setData({
        t: o,
        waiting_time: ++i
    });
}), t(e, "add_time", function(t) {
    var e = this, a = this;
    console.log(t, "22222222222222");
    var n = setInterval(function() {
        a.data.t;
        var t = e.data.waiting_time;
        a.change_time(t);
    }, 1e3);
    this.setData({
        time: n
    });
}),
 t(e, "changeIcon", function() {
    var t = this, e = this.data.controls;
    wx.getSystemInfo({
        success: function(a) {
            var n = a.windowWidth / 750 * 350, o = a.windowHeight - n;
            e[1] = {
                id: 2,
                iconPath: "../../../images/user/icon-30.png",
                position: {
                    bottom: o + 156,
                    right: 100,
                    width: 50,
                    height: 50
                },
                clickable: !0
            }, t.setData({
                winPath: {
                    w: a.windowWidth,
                    h: a.windowHeight
                },
                map_height: o,
                controls: e
            });
        }
    });0
}), t(e, "formSubmit", function(t) {
    wx.getStorageSync("user_info").id;
    var e = t.detail.formId;
    console.log(e, "22222222222222222"), this.deleteOrderHandler(e);
}), t(e, "onHide", function() {
    var t = this.data, e = t.timeTaskHandler, a = t.time;
    clearInterval(e), clearInterval(a);
}), t(e, "onUnload", function() {
    var t = this.data, e = t.timeTaskHandler, a = t.time;
    clearInterval(e), clearInterval(a);
}), t(e, "onShareAppMessage", function() {
    var t = i.shareAppMessage().title, e = i.shareAppMessage().imageUrl, a = i.shareAppMessage().desc, n = i.shareAppMessage().path;
    return console.log(i.shareAppMessage()), {
        title: t,
        imageUrl: e,
        desc: a,
        path: n
    };
}), e));